package com.boot.security.server.dao.mffl;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.mffl.MfflAdvertising;
import org.springframework.security.core.parameters.P;

@Mapper
public interface MfflAdvertisingDao {

    @Select("select * from mffl_advertising t where t.id = #{id}")
    MfflAdvertising getById(Long id);

    @Delete("delete from mffl_advertising where id = #{id}")
    int delete(Long id);

    int update(MfflAdvertising mfflAdvertising);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into mffl_advertising(path, url, skipUrl, `order`,serviceType, advertisingType, createTime) values(#{path}, #{url}, #{skipUrl}, #{order}, #{serviceType}, #{advertisingType}, now())")
    int save(MfflAdvertising mfflAdvertising);
    
    int count(@Param("params") Map<String, Object> params);

    List<MfflAdvertising> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    @Select("select * from mffl_advertising where advertisingType = #{advertisingType}  order by `order` limit #{count}")
    List<MfflAdvertising> getAdvertisingList(@Param("count") Integer count,@Param("advertisingType") Integer advertisingType);
}
